package org.net.cms.controller.app.payment;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.net.cms.config.Result;
import org.net.cms.controller.app.payment.vo.AppPaymentReqVO;
import org.net.cms.dao.PaymentDto;
import org.net.cms.service.payment.PaymentService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/pay")
@Tag(name = "APP - 缴费")
public class AppPaymentController {

    @Resource
    private PaymentService paymentService;

    /**
     * 查询所有缴费记录 (查列表)
     */
    @Operation(summary = "获取所有缴费记录")
    @GetMapping("/list")
    public Result getAll() {
        return Result.success(paymentService.appGetAll());
    }

    /**
     * 根据ID查询单个缴费记录
     */
    @Operation(summary = "根据ID获取缴费记录")
    @GetMapping("/get")
    @Parameter(name = "id", description = "缴费id", required = true)
    public Result getById(@Parameter int id) {
        PaymentDto record = paymentService.getById(id);
        return Result.success(record);
    }

    /**
     * 更新缴费记录
     */
    @Operation(summary = "更新缴费记录")
    @PutMapping("/update")
    public Result update(@RequestBody AppPaymentReqVO vo) {
        paymentService.update(vo);
        return Result.success();
    }

}
